package com.donleo.ssm.common;

import com.donleo.ssm.utils.ResponseLayResult;
import com.donleo.ssm.utils.UploadUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author liangd
 * date 2020-11-24 18:32
 * code 图片上传接口
 */
@RestController
@RequestMapping("/upload")
public class UploadController {

    @PostMapping("/img")
    public ResponseLayResult uploadFile(HttpServletRequest req, HttpServletResponse resp) {

        String path = UploadUtils.save(req, resp);
        return ResponseLayResult.createBySuccess(1,path);
    }
}
